﻿using System;
using System.Collections.Generic;

namespace Application.Repositories
{
    public class ProductRepository : IRepository<Product>
    {
        private IList<Product> Products { get; set; }

        public ProductRepository()
        {
            Products = new List<Product>
                       {
                           new Product
                               {
                                   Name = "Product A",
                                   Description = "Description for Product A",
                                   Price = 0.99
                               },
                           new Product
                               {
                                   Name = "Product B",
                                   Description = "Description for Product B",
                                   Price = 1.99
                               },
                           new Product
                               {
                                   Name = "Product C",
                                   Description = "Description for Product C",
                                   Price = 2.99
                               },
                           new Product
                               {
                                   Name = "Product D",
                                   Description = "Description for Product D",
                                   Price = 3.99
                               }
                       };
        }

        public IList<Product> FindAll()
        {
            return Products;
        }

        public void Add(ProductEditorViewModel productViewModel)
        {
            Products.Add(new Product { Name = productViewModel.Name, Description = productViewModel.Description, Price = productViewModel.Price });
        }
    }
}